package au.edu.unsw.infs3634.gamifiedlearning.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import au.edu.unsw.infs3634.gamifiedlearning.R;
import au.edu.unsw.infs3634.gamifiedlearning.model.HistoryMeetingListModel;
import au.edu.unsw.infs3634.gamifiedlearning.model.SendModel;

public class HistoryMeetingAdapter extends RecyclerView.Adapter<HistoryMeetingAdapter.HistoryMeetingHolder> {

    private List<HistoryMeetingListModel> historyMeetingListModelList ;

    private View view;

    public HistoryMeetingAdapter(List<HistoryMeetingListModel> historyMeetingListModelList) {
        this.historyMeetingListModelList = historyMeetingListModelList;
    }

    @NonNull
    @Override
    public HistoryMeetingAdapter.HistoryMeetingHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_history_meeting, parent, false);
        HistoryMeetingHolder historyMeetingHolder = new HistoryMeetingHolder(view);
        return historyMeetingHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull HistoryMeetingAdapter.HistoryMeetingHolder holder, int position) {
        HistoryMeetingListModel historyMeetingListModel = historyMeetingListModelList.get(position);
        holder.meetingName.setText(historyMeetingListModel.getMeetingName());
        holder.meetingPersonNum.setText(historyMeetingListModel.getPersons() + "人");
        holder.meetingTime.setText(historyMeetingListModel.getMeetingTime());
    }

    @Override
    public int getItemCount() {
        return historyMeetingListModelList.size();
    }


    class HistoryMeetingHolder extends RecyclerView.ViewHolder {

        private TextView meetingName;
        private TextView meetingPersonNum;
        private TextView meetingTime;


        public HistoryMeetingHolder(@NonNull View itemView) {
            super(itemView);
            this.meetingName = itemView.findViewById(R.id.meeting_name);
            this.meetingPersonNum = itemView.findViewById(R.id.meeting_person_num);
            this.meetingTime = itemView.findViewById(R.id.meeting_time);
        }
    }


}
